<?php
require_once 'include/common.inc.php';
require_once AK_ROOT.'include/admin.inc.php';
if(!file_exists(AK_ROOT.'configs/customer.config')) aexit('error');
if(empty($get_action)) {
	$config = readfromfile(AK_ROOT.'configs/customer.config');
	$configs = explode("\n", $config);
	$menu = '';
	foreach($configs as $c) {
		$c = trim($c);
		if($c == '') {
		} elseif(strpos($c, ',') === false) {
			$menu .= "<h1>$c</h1>";
		} else {
			list($url, $title) = explode(',', $c);
			$menu .= "<a href='$url'>$title</a><br />";
		}
	}
	echo $menu;
} elseif($get_action == 'variable') {
	$variable = $db->get_by('*', 'variables', "variable='$get_variable'");
	if($variable === false) {
		$db->insert('variables', array('variable' => $get_variable, 'value' => $get_default, 'description' => $get_desc));
		$value = $get_default;
	} else {
		$value = $variable['value'];
	}
	$smarty->assign('desc', htmlspecialchars($get_desc));
	$smarty->assign('var', htmlspecialchars($get_variable));
	$smarty->assign('value', htmlspecialchars($value));
	$smarty->assign('alias', htmlspecialchars($get_alias));
	displaytemplate('admincp_variable.htm');
} elseif($get_action == 'savevariable') {
	$value = array(
		'value' => $post_value
	);
	$db->update('variables', $value, "variable='$post_variable'");
	updatecache('globalvariables');
	adminmsg($lan['operatesuccess'], 'back');
}
?>